const ResponseModel = require('../models/response-model')
const logger = require('../utils/console-logger')

module.exports = function () {
    return async function ( ctx, next ) {
        try {
            await next()
            if (ctx.response.status === 404) {
                // logger.warn()
                ctx.response.body = ResponseModel.failure('未知请求')
            }
        } catch (error) {
            logger.error(error)
            ctx.response.body = ResponseModel.failure(error.message)
        }
    }
}
